<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>About buffer event callbacks</title>
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-base.css" />
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-medium.css" />

 </head>
 <body class="docs"><div class="navbar navbar-fixed-top">
  <div class="navbar-inner clearfix">
    <ul class="nav" style="width: 100%">
      <li style="float: left;"><a href="eventbufferevent.writebuffer.html">« EventBufferEvent::writeBuffer</a></li>
      <li style="float: right;"><a href="class.eventconfig.html">EventConfig »</a></li>
    </ul>
  </div>
</div>
<div id="breadcrumbs" class="clearfix">
  <ul class="breadcrumbs-container">
    <li><a href="index.html">PHP Manual</a></li>
    <li><a href="book.event.html">Event</a></li>
    <li>About buffer event callbacks</li>
  </ul>
</div>
<div id="layout">
  <div id="layout-content"><div id="eventbufferevent.about.callbacks" class="chapter">
 <h1>About buffer event callbacks</h1>

 <p class="para">
  An object of
  <span class="classname"><a href="class.eventbufferevent.html" class="classname">EventBufferEvent</a></span>
  class represents a
  <em class="emphasis">buffer event</em>
  . The asynchronous nature of I/O performed by Libevent implies that a
  socket(or other kind of file descriptor) is not always available. Event
  invokes corresponding callbacks when the resource becomes available for
  reading or writing, or when some event occurs(e.g. error, &quot;end of line&quot;
  etc.).
 </p>
 <p class="para">
  Read and write callbacks should match the following prototype:
 </p>
 <div class="methodsynopsis dc-description">
  <span class="methodname"><strong>callback</strong></span>(<span class="methodparam">
   <span class="type"><a href="class.eventbufferevent.html" class="type EventBufferEvent">EventBufferEvent</a></span>
    <code class="parameter">$bev</code>
   <span class="initializer"> = <strong><code>null</code></strong></span>
  </span>, <span class="methodparam">
   <span class="type"><a href="language.types.declarations.html#language.types.declarations.mixed" class="type mixed">mixed</a></span>
    <code class="parameter">$arg</code>
   <span class="initializer"> = <strong><code>null</code></strong></span>
  </span>): <span class="type"><span class="type void">void</span></span></div>

 <p class="para">
  <dl>
   
    <dt>

     <code class="parameter">bev</code>
    </dt>

    <dd>

     <p class="para">
      Associated
      <span class="classname"><a href="class.eventbufferevent.html" class="classname">EventBufferEvent</a></span>
      object.
     </p>
    </dd>

   
   
    <dt>

     <code class="parameter">arg</code>
    </dt>

    <dd>

     <p class="para">
      Custom variable attached to all callbacks via
      <span class="methodname"><a href="eventbufferevent.construct.html" class="methodname">EventBufferEvent::__construct()</a></span>
      , or
      <span class="methodname"><a href="eventbufferevent.setcallbacks.html" class="methodname">EventBufferEvent::setCallbacks()</a></span>
      .
     </p>
    </dd>

   
  </dl>

 </p>
 <p class="para">
  Event callback should match the following prototype:
 </p>
 <div class="methodsynopsis dc-description">
  <span class="methodname"><strong>callback</strong></span>(<span class="methodparam">
   <span class="type"><a href="class.eventbufferevent.html" class="type EventBufferEvent">EventBufferEvent</a></span>
    <code class="parameter">$bev</code>
   <span class="initializer"> = <strong><code>null</code></strong></span>
  </span>, <span class="methodparam">
   <span class="type">int</span>
    <code class="parameter">$events</code>
   <span class="initializer"> = 0</span>
  </span>, <span class="methodparam">
   <span class="type"><a href="language.types.declarations.html#language.types.declarations.mixed" class="type mixed">mixed</a></span>
    <code class="parameter">$arg</code>
   <span class="initializer"> = <strong><code>null</code></strong></span>
  </span>): <span class="type"><span class="type void">void</span></span></div>

 <p class="para">
  <dl>
   
    <dt>

     <code class="parameter">bev</code>
    </dt>

    <dd>

     <p class="para">
      Associated
      <span class="classname"><a href="class.eventbufferevent.html" class="classname">EventBufferEvent</a></span>
      object.
     </p>
    </dd>

   
   
    <dt>

     <code class="parameter">events</code>
    </dt>

    <dd>

     <p class="para">
      Bit mask of events:
      <strong><code>EventBufferEvent::READING</code></strong>
      ,
      <strong><code>EventBufferEvent::WRITING</code></strong>
      ,
      <strong><code>EventBufferEvent::EOL</code></strong>
      ,
      <strong><code>EventBufferEvent::ERROR</code></strong>
      and
      <strong><code>EventBufferEvent::TIMEOUT</code></strong>
      . See
      <a href="class.eventbufferevent.html#eventbufferevent.constants" class="link">EventBufferEvent constants</a>
     </p>
    </dd>

   
   
    <dt>

     <code class="parameter">arg</code>
    </dt>

    <dd>

     <p class="para">
      Custom variable attached to all callbacks via
      <span class="methodname"><a href="eventbufferevent.construct.html" class="methodname">EventBufferEvent::__construct()</a></span>
      , or
      <span class="methodname"><a href="eventbufferevent.setcallbacks.html" class="methodname">EventBufferEvent::setCallbacks()</a></span>
      .
     </p>
    </dd>

   
  </dl>

 </p>
</div>
</div></div></body></html>